package zhengqc.set;

import zhengqc.tree.BSTree;
import zhengqc.tree.TreeTraversalType;

import java.util.Arrays;

public class BSTreeSet<E extends Comparable<E>> implements Set<E> {

    private BSTree<E> bst;
    public BSTreeSet() {
        bst = new BSTree<>();
    }
    @Override
    public void add(E element) {
        bst.add(element);
    }

    @Override
    public void remove(E element) {
        bst.remove(element);
    }

    @Override
    public boolean contains(E element) {
        return bst.contains(element);
    }

    @Override
    public int getSize() {
        return bst.getSize();
    }

    @Override
    public boolean isEmpty() {
        return bst.isEmpty();
    }

    @Override
    public String toString() {
        return "BSTreeSet: " + Arrays.toString(this.bst.traversal(TreeTraversalType.INORDER).toArray());
    }
}
